/*global angular */
'use strict';

/**
 * @type {angular.Module}
 */
var app = angular.module('app1', ['ngRoute']);

app.config(function($routeProvider){
    $routeProvider.
	    when('/', {
	        controller: 'HelloCtrl',
	        templateUrl: 'index.html'
	    }).
	    when('/list', {
	        controller: 'ListCtrl',
	        templateUrl: 'list.html'
	    }).
	    when('/detail/:id', {
	        controller: 'DetailCtrl',
	        templateUrl: 'detail.html'
	    }).
	    when('/example1', {
	        controller: 'example1Ctrl',
	        templateUrl: 'example1.html'
	    }).
	    otherwise({
	        redirectTo: '/'
	    });
});

app.controller('DetailCtrl', function ($scope, $routeParams) {
	$scope.id = $routeParams.id;
});

app.controller('ListCtrl', function ($scope) {
});

app.controller('HelloCtrl', function ($scope) {
});

app.controller('example1Ctrl', function ($scope) {
});

app.controller('index', function ($scope) {
    $scope._click = function () {
        var result = 0;
        for (var key in $scope.members) {
            if ($scope.members[key].price != null)
                result += parseInt($scope.members[key].price);
        }
        $scope.result = result;
    }
});